<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<input type="file" name="jpg">
<button onclick="put()">上传</button>
<button onclick="window.history.go(-1)">返回</button>
<div id="list"></div>
</body>
<script src="frame/js/script_min.js"></script>
<script src="frame/js/util.js"></script>
<script>
    let put = ()=>{
        let input = document.querySelector('input[type="file"]');
        let data = new FormData();
        try{
            data.append(input.files[0].name.split(".")[1], input.files[0]);
        }catch (e){
            alert(`请选择上传文件`);
            return;
        }
        fetch('http://api.zankong.com.cn:1258/uploadFiles', {
            method: 'POST',
            body: data
        }).then(res=>{
            return res.json();
        }).then(res=>{
           console.log(res);
           let list = `<p><span>${input.files[0].name}---></span>${res[0].url}</p>`;
           $('#list').append(list);
        }).catch(e=>{
            alert(`参数错误`);
        });
    };
</script>
</html>